﻿using System;

class FillNSizedMatrix

            // Write a program that fills and prints a matrix of size (n, n)
{
    static void Main()
    {
        Console.Write("Enter the size 'N': ");
        int sizeN = int.Parse(Console.ReadLine());
        int[,] matrix = new int[sizeN, sizeN];
        int number = 1;

        for (int row = 0; row < matrix.GetLength(0); row++)
        {
            for (int col = 0; col <= row; col++)
            {
                matrix[sizeN - row + col - 1, col] = number++;
            }
        }

        for (int row = sizeN - 2; row >= 0; row--)
        {
            for (int col = row; col >= 0; col--)
            {
                matrix[row - col, sizeN - col - 1] = number++;
            }
        }
        for (int row = 0; row < matrix.GetLength(0); row++)
        {
            for (int col = 0; col < matrix.GetLength(0); col++)
            {
                Console.Write("{0,4}", matrix[row, col]);
            }
            Console.WriteLine();
        }
    }
}

